home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 676-700 / 683 / printfiles / english / rexx / prf.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-18  |  2KB  |  74 lines

  1. /* *************************************************** */
  2. /* printfiles Arexx Macro                              */
  3. /* © 1992 by K. Klingbeil                              */
  4. /* inserts files into the print list using AmigaDos    */
  5. /* pattern matching facilities                         */
  6. /* USAGE: rx prf -f<Arexx-Script> <insert> -r<remove>  */
  7. /* Example : rx prf -ftest.rexx #?test#? -rtest.h      */
  8. /* this examples inserts all files which contain       */
  9. /* the pattern  'test' info the print list, removes    */
  10. /* the file test.h and executes the Arexx-script       */
  11. /* test.rexx                                           */
  12. /* NOTE: Scripts that are generated from PrintFiles    */
  13. /* itself (Save button in the prefs window) contain    */
  14. /* a 'reset' command at the first line. You should     */
  15. /* call the prf macro with such a script as the first  */
  16. /* argument.                                           */
  17. /* *************************************************** */
  18.  
  19. options results
  20. options results
  21. if ~show(ports,'PRINTFILES')then do
  22.     address command 'printfiles'
  23. end
  24. if ~(show(ports,'PRINTFILES')) then return 5
  25.  
  26.  
  27. parse arg CmdLine
  28. p = words(CmdLine)
  29.  
  30. do i = 1 to p
  31.    pattern = word(CmdLine,i)
  32.    if left(pattern,2) == '-r' then removefile(substr(pattern,3))
  33.     else
  34.      if left(pattern,2) == '-f' then rxfile(substr(pattern,3))
  35.       else insertfile(pattern)
  36. end
  37. exit
  38.  
  39. rxfile: procedure
  40. parse arg template
  41. cmd =  'rx ' template
  42. address command cmd
  43. return 1
  44.  
  45. removefile: procedure
  46. parse arg template
  47. cmd =  'list >pipe:prf' template 'quick'
  48. address command cmd
  49. open('p','pipe:prf','r')
  50.  do while ~eof('p')
  51.   file = readln('p')
  52.   a = subword(file,1,1)
  53.   b = subword(file,2,1)
  54.   if a ~== '' & b == '' then address printfiles remfile a
  55.  end
  56. close('p')
  57.  
  58. return 1
  59.  
  60. insertfile: procedure
  61. parse arg template
  62. cmd =  'list >pipe:prf' template 'quick'
  63. address command cmd
  64. open('p','pipe:prf','r')
  65.  do while ~eof('p')
  66.   file = readln('p')
  67.   a = subword(file,1,1)
  68.   b = subword(file,2,1)
  69.   if a ~== '' & b == '' then address printfiles insfile a
  70.  end
  71. close('p')
  72. return  1
  73.  
  74.